<?php
/**
 * PddCopyLogs.php class file.
 * @author wudg <544038230@qq.com>
 * @date 2021/1/17- 下午4:56
 */

namespace common\jobs\models;

use common\models\pdd\PddCopyLogs as BasePddCopyLogs;

class PddCopyLogs extends BasePddCopyLogs
{

    /**
     * 自动录入新增和修改时间
     * @return mixed
     */
    public function beforeValidate()
    {
        $timestamp = time();
        if($this->getIsNewRecord())
        {
            $this->created_at = $timestamp;
            $this->updated_at = $timestamp;
        }else{
            $this->updated_at = $timestamp;
        }
        return parent::beforeValidate();
    }


    /**
     * 关联所属模板id
     * @return \yii\db\ActiveQuery
     */
    public function getTpl()
    {
        return $this->hasOne(PddFilterTpl::class,['id' => 'tpl_id']);
    }

}